<?php

class ReportCreator {
	
	private $templateStr;

	
	
	public function getTemplateStr() {
		return $this->templateStr;
	}
	public function setTemplateStr($templateStr) {
		$this->templateStr=$templateStr;
	}
	public function createPDFReport($placeHolderMap){
		$this->replacePlaceHolders("pdfreport.template",$placeHolderMap);
		return $this->getTemplateStr();
	}
	public function createHTMLReport($placeHolderMap){
		$this->replacePlaceHolders("htmlreport.template",$placeHolderMap);
		echo $this-> getTemplateStr();
		
	}
	private function replacePlaceHolders($fileName,$placeHolderMap){
		
		//Read File contents
		$fileName= "./conf/" .$fileName;
		$tempStr =file_get_contents($fileName);
		
		if(is_array ($placeHolderMap )){
			$mapkeys=array_keys($placeHolderMap);
			foreach($mapkeys as $key){
				$modkey= '{' .$key .'}';
				$value=$placeHolderMap[$key];
				$tempStr=str_replace($modkey,$value,$tempStr);
			}
			$this->setTemplateStr($tempStr);
		}
	}
}
?>